/*
 * calibration_callback.c
 *
 *  Created on: 2022年02月10日
 *      Author: Moon
 */


/* Includes ------------------------------------------------------------------*/
#include "ParmManage.h"
#include "cmd_process.h"
#include "pfc_task.h"
#include "system.h"

/* Private defines -----------------------------------------------------------*/

/* Public enum    -----------------------------------------------------------*/

/* Public Struct  -----------------------------------------------------------*/


/* Private Variable  ---------------------------------------------------------*/
//Pointer

//Array

//Const

/* Private function prototypes -----------------------------------------------*/


/***********************************************************************************
 * @brief
 * ex:
 * @par    None
 * @retval None
 **********************************************************************************/
ack_packet_t *collec_tube_callback(user_packet_t *user)
{
	ack_packet_t *ack;
#if 0    
    if (user->style == CMD_SET) //设置
	{
		// 用户数据处理
		memcpy(&pfcCtrl.tube.tubeS1, &user->data[0], 1);
		memcpy(&pfcCtrl.tube.tubeS1Mass, &user->data[1], 4);
		
		memcpy(&pfcCtrl.tube.tubeS2, &user->data[5], 1);
		memcpy(&pfcCtrl.tube.tubeS2Mass, &user->data[6], 4);
		
		memcpy(&pfcCtrl.tube.tubeS3, &user->data[10], 1);
		memcpy(&pfcCtrl.tube.tubeS3Mass, &user->data[11], 1);
		
		PPItemIWrite(PP_S1_ISUSE, &user->data[0], 1);
		PPItemIWrite(PP_S1_MASS, &user->data[1], 4);
		PPItemIWrite(PP_S2_ISUSE, &user->data[5], 1);
		PPItemIWrite(PP_S2_MASS, &user->data[6], 4);
		PPItemIWrite(PP_S3_ISUSE, &user->data[10], 1);
		PPItemIWrite(PP_S3_MASS, &user->data[11], 4);
		// 应答返回数据
		ack = Ack_Malloc(1);
		ack->data[0] = 0x00;
	
	}
	else if (user->style == CMD_READ) //读取
	{
		// 应答返回数据
		ack = Ack_Malloc(15);
		ack->data[0] = pfcCtrl.tube.tubeS1;
		ack->data[1] = pfcCtrl.tube.tubeS1Mass;
		
		ack->data[5] = pfcCtrl.tube.tubeS2;
		ack->data[6] = pfcCtrl.tube.tubeS2Mass;
		
		ack->data[10] = pfcCtrl.tube.tubeS3;
		ack->data[11] = pfcCtrl.tube.tubeS3Mass;
	}
	return ack;
#endif
}

/***********************************************************************************
 * @brief
 * ex:
 * @par    None
 * @retval None
 **********************************************************************************/
ack_packet_t *collec_setPPo_callback(user_packet_t *user)
{
	ack_packet_t *ack;
 #if 0   
    if (user->style == CMD_SET) //设置
	{
		// 用户数据处理
		memcpy(&pfcCtrl.P_Po, &user->data[0], 80);
		PPItemIWrite(PP_PP0, &user->data[0], 80);
		// 应答返回数据
		ack = Ack_Malloc(1);
		ack->data[0] = 0x00;
	
	}
	else if (user->style == CMD_READ) //读取
	{
		// 应答返回数据
		ack = Ack_Malloc(80);
		memcpy(&user->data[0], &pfcCtrl.P_Po, 80);
	}
	return ack;
	#endif
}

/***********************************************************************************
 * @brief
 * ex:
 * @par    None
 * @retval None
 **********************************************************************************/
ack_packet_t *collec_aeratPres_callback(user_packet_t *user)
{
	ack_packet_t *ack;
    #if 0
    if (user->style == CMD_SET) //设置
	{
		// 用户数据处理
		memcpy(&pfcCtrl.fillPres, &user->data[0], 4);
		PPItemIWrite(PP_ATMOS, &user->data[0], 4);
		// 应答返回数据
		ack = Ack_Malloc(1);
		ack->data[0] = 0x00;
	
	}
	else if (user->style == CMD_READ) //读取
	{
		// 应答返回数据
		ack = Ack_Malloc(4);
		memcpy(&user->data[0], &pfcCtrl.fillPres, 4);
	}
	return ack;
	#endif
}

/***********************************************************************************
 * @brief
 * ex:
 * @par    None
 * @retval None
 **********************************************************************************/
ack_packet_t *collec_airPres_callback(user_packet_t *user)
{
	#if 0
	ack_packet_t *ack;
    
    // 应答返回数据
	ack = Ack_Malloc(4);
	memcpy(&ack->data[0], &pfcCtrl.airPres, sizeof(float));  
	return ack;
	#endif
}

/***********************************************************************************
 * @brief
 * ex:
 * @par    None
 * @retval None
 **********************************************************************************/
ack_packet_t *collec_caliVacuum_callback(user_packet_t *user)
{
	#if 0
	ack_packet_t *ack;
    
    if (user->style == CMD_SET) //设置
	{
		// 用户数据处理
		memcpy(&pfcCtrl.caliVacuum.delayTime,      &user->data[0], 4);
		memcpy(&pfcCtrl.caliVacuum.speed,          &user->data[4], 4);
		memcpy(&pfcCtrl.caliVacuum.pumpPress,      &user->data[8], 4);
		memcpy(&pfcCtrl.caliVacuum.moleStartPress, &user->data[12], 4);
		memcpy(&pfcCtrl.caliVacuum.moleEndPress,   &user->data[16], 4);
		memcpy(&pfcCtrl.caliVacuum.moleMinTime,    &user->data[20], 4);
		memcpy(&pfcCtrl.caliVacuum.moleMaxTime,    &user->data[24], 4);
		memcpy(&pfcCtrl.caliVacuum.detectCycle,    &user->data[28], 4);
		memcpy(&pfcCtrl.caliVacuum.moleEnable,     &user->data[32], 1);
		memcpy(&pfcCtrl.caliVacuum.leakEnable,     &user->data[33], 1);
		
		PPItemIWrite(PP_CALI_VACUUM_DELAY,     &user->data[0], 4);
		PPItemIWrite(PP_CALI_VACUUM_SPEED,     &user->data[4], 4);
		PPItemIWrite(PP_CALI_VACUUM_UNLIM,     &user->data[8], 4);
		PPItemIWrite(PP_CALI_VACUUM_START_PRE, &user->data[12], 4);
		PPItemIWrite(PP_CALI_VACUUM_STOP_PRE,  &user->data[16], 4);
		PPItemIWrite(PP_CALI_VACUUM_MINTIM,    &user->data[20], 4);
		PPItemIWrite(PP_CALI_VACUUM_MAXTIM,    &user->data[24], 4);
		PPItemIWrite(PP_CALI_VACUUM_PERIOD,    &user->data[28], 4);
		PPItemIWrite(PP_CALI_VACUUM_TURBO_EN,  &user->data[32], 1);
		PPItemIWrite(PP_CALI_VACUUM_LEAK_EN,   &user->data[33], 1);
		// 应答返回数据
		ack = Ack_Malloc(1);
		ack->data[0] = 0x00;
	
	}
	else if (user->style == CMD_READ) //读取
	{
		// 应答返回数据
		ack = Ack_Malloc(34);
		ack->data[0] = pfcCtrl.caliVacuum.delayTime;
		ack->data[4] = pfcCtrl.caliVacuum.speed;
		ack->data[8] = pfcCtrl.caliVacuum.pumpPress;
		ack->data[12] = pfcCtrl.caliVacuum.moleStartPress;
		ack->data[16] = pfcCtrl.caliVacuum.moleEndPress;
		ack->data[20] = pfcCtrl.caliVacuum.moleMinTime;
		ack->data[24] = pfcCtrl.caliVacuum.moleMaxTime;
		ack->data[28] = pfcCtrl.caliVacuum.detectCycle;
		ack->data[32] = pfcCtrl.caliVacuum.moleEnable;
		ack->data[33] = pfcCtrl.caliVacuum.leakEnable;
	}
	return ack;
	#endif
}

/***********************************************************************************
 * @brief
 * ex:
 * @par    None
 * @retval None
 **********************************************************************************/
ack_packet_t *collec_adsorVacuum_callback(user_packet_t *user)
{
	#if 0
	ack_packet_t *ack;
    
    if (user->style == CMD_SET) //设置
	{
		// 用户数据处理
		memcpy(&pfcCtrl.adsorVacuum.delayTime, &user->data[0], 4);
		memcpy(&pfcCtrl.adsorVacuum.speed, &user->data[4], 4);
		memcpy(&pfcCtrl.adsorVacuum.pumpPress, &user->data[8], 4);
		memcpy(&pfcCtrl.adsorVacuum.moleStartPress, &user->data[12], 4);
		memcpy(&pfcCtrl.adsorVacuum.moleEndPress, &user->data[16], 4);
		memcpy(&pfcCtrl.adsorVacuum.moleMinTime, &user->data[20], 4);
		memcpy(&pfcCtrl.adsorVacuum.moleMaxTime, &user->data[24], 4);
		memcpy(&pfcCtrl.adsorVacuum.detectCycle, &user->data[28], 4);
		memcpy(&pfcCtrl.adsorVacuum.moleEnable, &user->data[32], 1);
		memcpy(&pfcCtrl.adsorVacuum.leakEnable, &user->data[33], 1);
		
		PPItemIWrite(PP_ADSORB_VACUUM_DELAY,     &user->data[0], 4);
		PPItemIWrite(PP_ADSORB_VACUUM_SPEED,     &user->data[4], 4);
		PPItemIWrite(PP_ADSORB_VACUUM_UNLIM,     &user->data[8], 4);
		PPItemIWrite(PP_ADSORB_VACUUM_START_PRE, &user->data[12], 4);
		PPItemIWrite(PP_ADSORB_VACUUM_STOP_PRE,  &user->data[16], 4);
		PPItemIWrite(PP_ADSORB_VACUUM_MINTIM,    &user->data[20], 4);
		PPItemIWrite(PP_ADSORB_VACUUM_MAXTIM,    &user->data[24], 4);
		PPItemIWrite(PP_ADSORB_VACUUM_PERIOD,    &user->data[28], 4);
		PPItemIWrite(PP_ADSORB_VACUUM_TURBO_EN,  &user->data[32], 1);
		PPItemIWrite(PP_ADSORB_VACUUM_LEAK_EN,   &user->data[33], 1);
		// 应答返回数据
		ack = Ack_Malloc(1);
		ack->data[0] = 0x00;
	
	}
	else if (user->style == CMD_READ) //读取
	{
		// 应答返回数据
		ack = Ack_Malloc(34);
		ack->data[0] = pfcCtrl.adsorVacuum.delayTime;
		ack->data[4] = pfcCtrl.adsorVacuum.speed;
		ack->data[8] = pfcCtrl.adsorVacuum.pumpPress;
		ack->data[12] = pfcCtrl.adsorVacuum.moleStartPress;
		ack->data[16] = pfcCtrl.adsorVacuum.moleEndPress;
		ack->data[20] = pfcCtrl.adsorVacuum.moleMinTime;
		ack->data[24] = pfcCtrl.adsorVacuum.moleMaxTime;
		ack->data[28] = pfcCtrl.adsorVacuum.detectCycle;
		ack->data[32] = pfcCtrl.adsorVacuum.moleEnable;
		ack->data[33] = pfcCtrl.adsorVacuum.leakEnable;
	}
	return ack;
	#endif
}

/***********************************************************************************
 * @brief
 * ex:
 * @par    None
 * @retval None
 **********************************************************************************/
ack_packet_t *collec_adsorb_callback(user_packet_t *user)
{
	#if 0
	ack_packet_t *ack;
    
    if (user->style == CMD_SET) //设置
	{
		// 用户数据处理
		memcpy(&pfcCtrl.adsorb.absPresError,      &user->data[0], 4);
		memcpy(&pfcCtrl.adsorb.relatPresError,    &user->data[4], 4);
		memcpy(&pfcCtrl.adsorb.balanceGap,        &user->data[8], 4);
		memcpy(&pfcCtrl.adsorb.balanceMinTim,     &user->data[12], 4);
		memcpy(&pfcCtrl.adsorb.balanceMaxTim,     &user->data[16], 4);
		memcpy(&pfcCtrl.adsorb.balanceMinTim_995, &user->data[20], 4);
		
		PPItemIWrite(PP_ABSOLUTE_PRE_THRESHOLD, &user->data[0], 4);
		PPItemIWrite(PP_RELATIVE_PRE_THRESHOLD, &user->data[4], 4);
		PPItemIWrite(PP_PRE_BALANCE_PERIOD,     &user->data[8], 4);
		PPItemIWrite(PP_PRE_BALANCE_MINTIM,     &user->data[12], 4);
		PPItemIWrite(PP_PRE_BALANCE_MAXTIM,     &user->data[16], 4);
		PPItemIWrite(PP_PRE995_BALANCE_MINTIM,  &user->data[20], 4);
		// 应答返回数据
		ack = Ack_Malloc(1);
		ack->data[0] = 0x00;
	
	}
	else if (user->style == CMD_READ) //读取
	{
		// 应答返回数据
		ack = Ack_Malloc(24);
		ack->data[0]  = pfcCtrl.adsorb.absPresError;
		ack->data[4]  = pfcCtrl.adsorb.relatPresError;
		ack->data[8]  = pfcCtrl.adsorb.balanceGap;
		ack->data[12] = pfcCtrl.adsorb.balanceMinTim;
		ack->data[16] = pfcCtrl.adsorb.balanceMaxTim;
		ack->data[20] = pfcCtrl.adsorb.balanceMinTim_995;
	}
	return ack;
	#endif
}

/***********************************************************************************
 * @brief
 * ex:
 * @par    None
 * @retval None
 **********************************************************************************/
ack_packet_t *collec_fillPres_callback(user_packet_t *user)
{
	#if 0
	ack_packet_t *ack;
    
    if (user->style == CMD_SET) //设置
	{
		// 用户数据处理
		memcpy(&pfcCtrl.fillPres, &user->data[0], 4);
		PPItemIWrite(PP_FILLING_PRE, &user->data[0], 4);
		// 应答返回数据
		ack = Ack_Malloc(1);
		ack->data[0] = 0x00;
	
	}
	else if (user->style == CMD_READ) //读取
	{
		// 应答返回数据
		ack = Ack_Malloc(4);
		ack->data[0]  = pfcCtrl.fillPres;
	}
	return ack;
	#endif
}

/***********************************************************************************
 * @brief
 * ex:
 * @par    None
 * @retval None
 **********************************************************************************/
ack_packet_t *collec_freeV_callback(user_packet_t *user)
{
	#if 0
	ack_packet_t *ack;
    
	// 应答返回数据
	ack = Ack_Malloc(9);
	memcpy(&ack->data[0], &pfcCtrl.freeV.tubeNo, 1); 
	memcpy(&ack->data[1], &pfcCtrl.freeV.mormalFreeV, sizeof(float));  
	memcpy(&ack->data[5], &pfcCtrl.freeV.coldFreeV, sizeof(float));  
	
	return ack;
	#endif
}

/******************* (C) COPYRIGHT 2021 CIQTEK Samuel *****END OF FILE****/

